package com.suncreate.zhtz.iot.service.impl;

import com.suncreate.zhtz.iot.model.ScSignalRunSituation;
import com.suncreate.zhtz.iot.mapper.ScSignalRunSituationDao;
import com.suncreate.zhtz.iot.service.ScSignalRunSituationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ScSignalRunSituation)表服务实现类
 *
 * @author makejava
 * @since 2021-09-10 16:13:14
 */
@Service("scSignalRunSituationService")
public class ScSignalRunSituationServiceImpl implements ScSignalRunSituationService {
    @Resource
    private ScSignalRunSituationDao scSignalRunSituationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param situationKey 主键
     * @return 实例对象
     */
    @Override
    public ScSignalRunSituation queryById(String situationKey) {
        return this.scSignalRunSituationDao.queryById(situationKey);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ScSignalRunSituation> queryAllByLimit(int offset, int limit) {
        return this.scSignalRunSituationDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param scSignalRunSituation 实例对象
     * @return 实例对象
     */
    @Override
    public ScSignalRunSituation insert(ScSignalRunSituation scSignalRunSituation) {
        this.scSignalRunSituationDao.insert(scSignalRunSituation);
        return scSignalRunSituation;
    }

    /**
     * 修改数据
     *
     * @param scSignalRunSituation 实例对象
     * @return 实例对象
     */
    @Override
    public ScSignalRunSituation update(ScSignalRunSituation scSignalRunSituation) {
        this.scSignalRunSituationDao.update(scSignalRunSituation);
        return this.queryById(scSignalRunSituation.getSituationKey());
    }

    /**
     * 通过主键删除数据
     *
     * @param situationKey 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String situationKey) {
        return this.scSignalRunSituationDao.deleteById(situationKey) > 0;
    }
}
